package com.briup.web.servlet;

import com.briup.bean.Customer;
import com.briup.bean.ShopCar;
import com.briup.service.IShopCarService;
import com.briup.service.impl.IShopCarServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 王若龙
 * @CreateTime 2022-09-27 10:26
 */
@WebServlet("/delete")
public class ShopCarDeleteServlet extends HttpServlet {

    private IShopCarService service = new IShopCarServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int bookId = Integer.parseInt(req.getParameter("bookId"));
        Customer customer = (Customer) req.getSession().getAttribute("customer");
        Integer customerId = customer.getId();
        service.deleteShop(bookId, customerId);
        resp.sendRedirect("/shopCarAdd");
    }
}
